// 全局apiurl
// var baseUrl  = "http://10.36.1.67/bzapp/";
// // var baseUrl = "http://10.36.1.77/bzapp/"
// var userId = ;
// var bzId = bzId;


var peopleList = [];
//获取班组简介
var fd = new FormData();
fd.append("json", JSON.stringify({
    "userId": userId,
    "data": {
        "bzId": bzId
    }
}));
// 人员简介字段渲染

$.ajax({
    url: baseUrl + 'api/Culture/GetMeetAbstract',
    data: {
        json: JSON.stringify({
            "userId": userId,
            "data": {
                "bzId": bzId
            }
        })
    },
    type: "POST",
    // contentType:false,
    // processData:false,
    success: function (data) {
        console.log(data);
        if (data.code == 0) {
            classinstru(data.data)
        }

    }
})

function classinstru(item) {
    var x = '<div class="content-item">班组成员' + item.Member + '人</div><div class="content-item">工程师' + item.Engineer + '人</div><div class="content-item">技师' + item.Technician + '人</div>' +
        '<div class="content-item">大专及以上学历' + item.Education + '人</div><div class="content-item">助理工程师' + item.AssistantEngineer + '人</div><div class="content-item">高级工' + item.Expert + '人</div>' +
        '<div class="content-item">中共党员' + item.PartyMember + '人</div><div class="content-item">高级技师' + item.ExpertTechnician + '人</div><div class="content-item">平均年龄' + (Number(item.AverageAage)).toFixed(0) + '岁</div>'
    $(".content").html(x);
}
//获取文化墙信息
getwall();

function getwall() {
    $.ajax({
        // contentType:"application/json; charset=utf-8",
        url: baseUrl + 'api/Culture/GetWallInfo',
        data: fd,
        type: "POST",
        contentType: false,
        processData: false,
        success: function (data) {
            if (data.code == 0) {
                mainclass(data.data)
            }
        }
    })
}

var key = "";

function imgupload(index) {
   $(".qcodemsg1").children().remove();
    var strmsg1 = bzId + "|风采剪影|"+index;
     jQuery('.qcodemsg1').qrcode({
         text: utf16to8(strmsg1),
         width: 110,
         height: 110,
     });
    key = index;
    $('.upload').css('background-image', 'url(../img/system/upload.jpg)')
    $('#modifyDatetwo').val('')
    $('#uploadUsertwo').val('')
    var DateTime = new Date();
    var year = DateTime.getFullYear();
    var month = DateTime.getMonth() + 1;
    var day = DateTime.getDate();
    var time = year + '-' + month + '-' + day;
    $('#modifyDatetwo').val(time);
}
// mainclass({pic:[]})
// mainclass(11)
$(".img-c").click(
    function () {
        $(".img-c").removeClass("active");
        $(this).addClass("active");
    }
)
var arr = []; //班组荣誉
function mainclass(item) {
    $(".textareainstr").html(item.summary);
    $(".hopeMessage").val(item.vision);
    $(".titlep").val(item.slogan);
    arr = [];
    var brr = []; //风采剪影
    var bzHonr = [];
    var czHonr = [];
    if (item.pics) {
        item.pics.forEach(
            function (obj) {
                if (obj.filetype == 1) {
                    arr.push(obj);
                    bzHonr.push(obj);
                } else {
                    brr.push(obj);
                    czHonr.push(obj);
                }
            }
        )
    }
    honerList(arr)
    var html = ''
    for (var k = 0; k < bzHonr.length; k++) {
        html += '<div class="img-h-list"><img src="' +
            bzHonr[k].filepath + '" alt=""><div class="img-clicks" data-id="' + bzHonr[k].fileid + '"><img src="../img/system/mode_close.png" alt=""  > </div></div></div>'

    }
    var html1 = "";
    for (var k = 0; k < czHonr.length; k++) {
        $(".img-h-" + czHonr[k].key).html(
            '<img src="' + czHonr[k].filepath + '" alt=""></img>'
        )
        $(".img-click-" + czHonr[k].key).css("display", "block");
        $(".img-click-" + czHonr[k].key).attr("data-id", czHonr[k].fileid)
        // $(".img-h-"+czHonr[i].key).children().remove();
        $(".img-c-" + czHonr[k].key).css("display", "none");
    }
    $('.honner-img').html(html);
    // $(".honner-img-two").html(html1);

    // 上传图片开始
    // $(".img-h-list").click(
    //     function(){
    //        console.log(bzHonr);
    //        var item = 
    //     }
    // )
    fileinfosArr = []
    deletArr = []


    var imgflag = false; //是否有选择图片
    var fileinfosArrt = []
    var deletArrt = []
    var imgUrl = ''
    // var param = {
    // 	userId: userId,
    // 	data: {
    // 		bzId: bzId, //班组ID
    // 		fileinfos: []
    // 	}
    // }
    $('.img-click').click(function () {
        var fileId = $(this).attr('data-id')
        var indexdata = $(this).attr('data-index');
        if (fileId) {
            deletArr.push(fileId);
        }
        $(this).css("display", "none");
        $(".img-c-" + indexdata).css("display", "block");
        $(".img-h-" + indexdata).html('');
        $('.honner-r').css('background-color', '#fa8803')
        $(this).addClass("active");
    })
    $('.img-clicks').click(function () {
        var fileId = $(this).attr('data-id')
        deletArrt.push(fileId)
        $(this).parent().remove()
        $('.honner-r').css('background-color', '#fa8803')
    })
    $(document).off('change', '#imgUpload').on('change', '#imgUpload',
        function () {
            var num = $('.img-h-list').length
            if (num > 11) {
                alert('只能上传12张图片')
                $('.honner-r').css('background-color', '#e5e5e5')
            } else {
                var files = $('#imgUpload').get(0).files[0];
                if (!(files.size)) {
                    alert("上传图片名称不能带特殊符号，请重新上传");
                    // alert("上传图片名称带有特殊符号或上传的图片位置在U盘，请重新上传");
                    return false;
                }
                if (files.size / (1024 * 1024) > 8) {
                    $(".imgtopp").show();
                    return false;
                } else {
                    $(".imgtopp").hide();
                }
                var reader = new FileReader()
                reader.readAsDataURL(files)
                reader.onloadend = function () {
                    imgUrl = reader.result
                    $('.upload').css('background-image', 'url(' + reader.result + ')');
                    imgflag = true;
                }
            }
        })

    // $(".upload").off('change','#imgUploadtwo').live('change','#imgUploadtwo',

    $(document).off('change', '#imgUploadtwo').on('change', '#imgUploadtwo',
        function () {
            var num = $('.img-h-listtwo').length

            if (key === "") {
                alert('请选择上传图片的位置');

                return false;
            }
            if (false) {
                alert('只能上传8张图片')
                $('.honner-r').css('background-color', '#e5e5e5')
            } else {
                var files = $('#imgUploadtwo').get(0).files[0];
                if (!(files.size)) {
                    alert("上传图片名称不能带特殊符号，请重新上传");
                    // alert("上传图片名称带有特殊符号或上传的图片位置在U盘，请重新上传");
                    return false;
                }
                if (files.size / (1024 * 1024) > 8) {
                    $(".imgtopptwo").show();
                    // imgflag = true;
                    return false;
                } else {
                    $(".imgtopptwo").hide();
                }
                var reader = new FileReader()

                var newfile = new File([files], new Date().getTime(), {
                    type: files.type
                });
                reader.readAsDataURL(newfile)
                // reader.readAsDataURL(files)
                reader.onloadend = function () {
                    imgUrl = reader.result
                    $('.upload').css('background-image', 'url(' + reader.result + ')')
                    imgflag = true;
                }
            }
        })
    // function addimg(){
    // //新增之前
    $('.add_upload').unbind('click').click(function () {
        var time = $('#modifyDate').val()
        var user = $('#uploadUserdec').val()
        if (time == '') {
            $('.uplod_time').show()
        } else {
            $('.uplod_time').hide()
        }
        if (user == '') {
            $('.uplod_user').show()
        } else {
            $('.uplod_user').hide()
        }
        if (!imgflag) {
            $('.upload_img').show();
            return false;
        } else {
            $('.upload_img').hide()
        }
        if ((user != '')) {

            // if(true) {
            if (time == "") {
                var DateTime = new Date();
                var year = DateTime.getFullYear();
                var month = DateTime.getMonth() + 1;
                var day = DateTime.getDate();
                time = year + '-' + month + '-' + day;
                $('#modifyDate').val(time);
            }
            var html = '<div class="img-h-list"><img src="' +
                imgUrl + '" alt=""><div class="img-clicks img-click-two" onclick="delete()"  index="' + fileinfosArr.length + '"><img src="../img/system/mode_close.png" alt=""  > </div></div></div>'
            $('.honner-img').append(html)
            $(".img-clicks").click(
                function () {
                    console.log($(this).attr('index'))
                    var indec = $(this).attr('index');
                    fileinfosArr.splice(indec, 1);
                    $(this).parent().remove()
                }
            )

            var obj = {
                data: {
                    filetype: 1,
                    modifyDate: $('#modifyDate').val(),
                    modifyusername: $('#uploadUser').val(),
                    description: $("#uploadUserdec").val(),
                },
                fileObj: $('#imgUpload').get(0).files[0]
            }
            fileinfosArr.push(obj)
            $('.upload').css('background-image', 'url(../img/system/upload.jpg)')
            // $('#modifyDate').val('')
            var DateTime = new Date();
            var year = DateTime.getFullYear();
            var month = DateTime.getMonth() + 1;
            var day = DateTime.getDate();
            time = year + '-' + month + '-' + day;
            $('#modifyDate').val(time);
            $('#uploadUserdec').val("")
            $('#uploadUser').val('')
            console.log('66666', fileinfosArr)
            imgflag = false;
        }
    })
    $('.add_upload-two').click(function () {
        var time = $('#modifyDatetwo').val()
        var user = $('#uploadUsertwo').val()
        if (time == '') {
            $('.uplod_time').show()
        } else {
            $('.uplod_time').hide()
        }
        if (user == '') {
            $('.uplod_user').show()
        } else {
            $('.uplod_user').hide()
        }
        if (!imgflag) {
            $('.upload_img').show();
            return false;
        } else {
            $('.upload_img').hide()
        }
        // if($(".upload").css("background-image").substring(0,9)!='url("data'){
        //     $('.upload_img').show();
        //     return false;
        // }else{
        // 	$('.upload_img').hide()
        // }
        // if(user != '') {
        if (true) {
            if (time == "") {
                var DateTime = new Date();
                var year = DateTime.getFullYear();
                var month = DateTime.getMonth() + 1;
                var day = DateTime.getDate();
                time = year + '-' + month + '-' + day;
                $('#modifyDatetwo').val(time);
            }
            var html = '<div class="img-h-listtwo"><img src="' +
                imgUrl + '" alt=""><div class="img-click img-click-two1" onclick="delete()"  index="' + fileinfosArrt.length + '"><img src="../img/system/mode_close.png" alt=""  > </div></div></div>'
            // $('.honner-img-two').append(html)

            if (key !== "") {
                $(".img-h-" + key).html(
                    '<img src="' + imgUrl + '" alt=""></img>'
                )
                console.log($(".img-h-" + key))
                $(".img-click-" + key).css("display", "block");
                // $(".img-h-"+key).children().remove();
                $(".img-c-" + key).css("display", "none");
            }

            $(".img-click").click(
                function () {
                    var indexc;
                    var indexdata = $(this).attr('data-index');
                    for (var j = 0; j < fileinfosArrt.length; j++) {
                        if (fileinfosArrt[j].data.key == indexdata) {
                            indexc = j;
                        }
                    }
                    if (indexc) {
                        fileinfosArrt.splice(indexc, 1);
                    }
                    $(this).css("display", "none");
                    $(".img-c-" + key).css("display", "block");
                    $(".img-h-" + key).html('');
                }
            )
            $(".img-c").removeClass("active");
            var obj = {
                data: {
                    filetype: 0,
                    modifyDate: $('#modifyDatetwo').val(),
                    modifyusername: $('#uploadUsertwo').val(),
                    description: $("#uploadUserdectwo").val(),
                    key: key
                },
                fileObj: $('#imgUploadtwo').get(0).files[0]
            }
            fileinfosArrt.push(obj)
            $('.upload').css('background-image', 'url(../img/system/upload.jpg)')
            $('#modifyDatetwo').val('')
            $('#uploadUsertwo').val('')

            var DateTime = new Date();
            var year = DateTime.getFullYear();
            var month = DateTime.getMonth() + 1;
            var day = DateTime.getDate();
            time = year + '-' + month + '-' + day;
            $('#modifyDatetwo').val(time);
            console.log('66666', fileinfosArrt)
            imgflag = false;
            key = ""
        }
    })
    //确定上传
    $('#sureUpload').unbind('click').click(function () {
        var fileArr = []
        var UpdateFile = new FormData();
        var param = {
            userId: userId,
            data: {
                bzId: bzId, //班组ID
                fileinfos: []
            }
        }
        fileinfosArr.forEach(
            function (item) {
                param.data.fileinfos.push(item.data)
                UpdateFile.append(
                    'file', item.fileObj
                )
            })
        if (deletArrt.length > 0) {
            param.data.deletefileids = deletArrt.join(",")
        }
        UpdateFile.append(
            'json', JSON.stringify(param)
        )
        $(".loading-img").show();
        $.ajax({
            url: baseUrl + 'api/Culture/UploadFile',
            data: UpdateFile,
            type: "POST",
            contentType: false,
            processData: false,
            success: function (res) {
                $(".loading-img").hide();
                param.data.fileinfos = [];
                $('.upload').css('background-image', 'url(../img/system/upload.jpg)')
                if (res.code == 0) {
                    if (changeMsg == "zred") {
                        location.href = "./detail1.html?number=2&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
                    } else if (changeMsg == "zgblue") {
                        location.href = "./detail2.html?number=2&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
                    } else if (changeMsg == "zgreen") {
                        location.href = "./detail3.html?number=2&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
                    } else if (changeMsg == "zorange") {
                        location.href = "./detail4.html?number=2&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
                    }
                    // fileinfosArr = []
                    // deletArr=[]
                    // imgUrl=''
                    // $('.next-diago').hide()
                    // getwall();
                }

            }
        })
    })
    $('#sureUpload-two').unbind('click').click(function () {
        var fileArr = []
        var UpdateFile = new FormData();
        var param = {
            userId: userId,
            data: {
                bzId: bzId, //班组ID
                fileinfos: []
            }
        }

        fileinfosArrt.forEach(
            function (item) {
                param.data.fileinfos.push(item.data)
                UpdateFile.append(
                    'file', item.fileObj
                )
            })
        if (deletArr.length > 0) {
            param.data.deletefileids = deletArr.join(",")
        }
        UpdateFile.append(
            'json', JSON.stringify(param)
        )
        $(".loading-img").show();
        $.ajax({
            url: baseUrl + 'api/Culture/UploadFile',
            data: UpdateFile,
            type: "POST",
            contentType: false,
            processData: false,
            success: function (res) {
                $(".loading-img").hide();
                param.data.fileinfos = [];
                $('.upload').css('background-image', 'url(../img/system/upload.jpg)')
                if (res.code == 0) {
                    if (changeMsg == "zred") {
                        location.href = "./detail1.html?number=3&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
                    } else if (changeMsg == "zgblue") {
                        location.href = "./detail2.html?number=3&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
                    } else if (changeMsg == "zgreen") {
                        location.href = "./detail3.html?number=3&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
                    } else if (changeMsg == "zorange") {
                        location.href = "./detail4.html?number=3&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
                    }
                    // fileinfosArrt = []
                    // deletArr=[]
                    // imgUrl=''
                    // $('.next-diago-two').hide()
                    // getwall();
                }
            }
        })
    })

    function deleteARR(index) {
    }
    var brrObj = "";
    for (var i = 0; i < brr.length; i++) {
        if (brr[i].key == 0) {
            var divdom = '<img class="ani" swiper-animate-effect="honnerT" swiper-animate-duration="1s" swiper-animate-delay="0.5s" src="' + brr[i].filepath + '" alt="">';
            $(".img-0").html(divdom)
        }
        if (brr[i].key == 1) {
            var divdom = '<img class="ani" swiper-animate-effect="honnerT" swiper-animate-duration="1s" swiper-animate-delay="1s" src="' + brr[i].filepath + '" alt="">';
            $(".img-1").html(divdom)
        }
        if (brr[i].key == 2) {
            var divdom = '<img class="ani" swiper-animate-effect="honnerT" swiper-animate-duration="1s" swiper-animate-delay="1.5s" src="' + brr[i].filepath + '" alt="">';
            $(".img-2").html(divdom)
        }
        if (brr[i].key == 3) {
            var divdom = '<img src="' + brr[i].filepath + '" alt="">';
            $(".img-3").html(divdom)
        }
        if (brr[i].key == 4) {
            var divdom = '<img class="ani" swiper-animate-effect="honnerRight" swiper-animate-duration="1s" swiper-animate-delay="2.5s" src="' + brr[i].filepath + '" alt="">';
            $(".img-4").html(divdom)
        }
        if (brr[i].key == 5) {
            var divdom = '<img class="ani" swiper-animate-effect="honnerRight" swiper-animate-duration="1s" swiper-animate-delay="3s" src="' + brr[i].filepath + '" alt="">';
            $(".img-5").html(divdom)
        }
        if (brr[i].key == 6) {
            var divdom = '<img class="ani" swiper-animate-effect="honnerRight" swiper-animate-duration="1s" swiper-animate-delay="3.5s" src="' + brr[i].filepath + '" alt="">';
            $(".img-6").html(divdom)
        }
        if (brr[i].key == 7) {
            var divdom = '<img class="ani" swiper-animate-effect="honnerBottom" swiper-animate-duration="1s" swiper-animate-delay="4s" src="' + brr[i].filepath + '" alt="">';
            $(".img-7").html(divdom)
        }
    }
}

function newprew(e){
    var src = e.target.src;
    $(".newposition").css("display","block");
    console.log(src)
    $(".newposition img").attr("src",src);


}
$(".content-item-scroller").click(
    function(){
        $(".newposition").css("display","none");
    }
)
function honerList(arr) {
    var arrObj = "";
    if ((arr.length % 2) == 0) {
        var honnerList = [];
        for (var n = 0; n < (arr.length / 2); n++) {
            honnerList += '<div class="top-honner" >' +
                '<div class="item-img">' +
                '<img data-preview-src=""  onclick="newprew(event)" src="' + arr[2 * n].filepath + '" alt="">' +
                '</div>' +
                '<div class="item-text">' + (arr[2 * n].description ? arr[2 * n].description : "") +
                '</div>' +

                '<div class="toimg">' +
                '<img  src="../img/detail/1/' + changeMsg + '.png" alt="">' +
                '</div>' +
                '</div>' +
                '<div class="bottom-honner">' +
                '<div class="toimg">' +
                '<img  src="../img/detail/1/' + changeMsg + '.png" alt="">' +
                '</div>' +
                '<div class="item-text">' +
                (arr[2 * n + 1].description ? arr[2 * n + 1].description : "") +
                '</div>' +
                '<div class="item-img">' +
                '<img data-preview-src="" onclick="newprew(event)"  src="' + arr[2 * n + 1].filepath + '" alt="">' +
                '</div>' +
                '</div>'
        }
        console.log(honnerList)
        $(".m-m-t").html(honnerList);
    } else {
        var honnerSelect = [];
        for (var n = 0; n < Math.floor(arr.length / 2); n++) {
            honnerSelect += '<div class="top-honner" onclick="newprew(event)">' +
                '<div class="item-img">' +
                '<img data-preview-src="" onclick="newprew(event)" src="' + arr[2 * n].filepath + '" alt="">' +
                '</div>' +
                '<div class="item-text">' +
                (arr[2 * n].description ? arr[2 * n].description : "") +
                '</div>' +
                '<div class="toimg">' +
                '<img  src="../img/detail/1/' + changeMsg + '.png" alt="">' +
                '</div>' +
                '</div>' +
                '<div class="bottom-honner">' +
                '<div class="toimg">' +
                '<img  src="../img/detail/1/' + changeMsg + '.png" alt="">' +
                '</div>' +
                '<div class="item-text">' +
                (arr[2 * n + 1].description ? arr[2 * n + 1].description : "") +
                '</div>' +
                '<div class="item-img">' +
                '<img data-preview-src="" onclick="newprew(event)" src="' + arr[2 * n + 1].filepath + '" alt="">' +
                '</div>' +
                '</div>'
        }
        honnerSelect += '<div class="top-honner" onclick="newprew(event)">' +
            '<div class="item-img">' +
            '<img data-preview-src="" onclick="newprew(event)" src="' + arr[arr.length - 1].filepath + '" alt="">' +
            '</div>' +
            '<div class="item-text">' +
            (arr[arr.length - 1].description ? arr[arr.length - 1].description : "") +
            '</div>' +
            '<div class="toimg">' +
            '<img  src="../img/detail/1/' + changeMsg + '.png" alt="">' +
            '</div>' +
            '</div>';

        $(".m-m-t").html(honnerSelect);
        
    }
    var lengthW = $(".m-m-person").children().length * 220 + 40;
    if ($(".m-m-t").children().length > 7) {
        $(".m-m-t").css('width', lengthW + "px");
        $(".top-honner").css("float", "left");
        $(".bottom-honner").css("float", "left");
    } else {
        $(".m-m-t").css('width', "100%");
        $(".top-honner").css("float", "none");
        $(".bottom-honner").css("float", "none");
    }
}





//上传风采剪影、班组荣誉
var UpdateFile = new FormData();
var UpdateFileInfo = {
    userId: userId,
    data: {
        bzId: bzId,
        deletefileids: "",
        description: "",
        filetype: "0",
    }
}

UpdateFile.append(
    'json', JSON.stringify(UpdateFileInfo)
)
$.ajax({
    url: baseUrl + 'api/Culture/UploadFile',
    data: UpdateFile,
    type: "POST",
    contentType: false,
    processData: false,
    success: function (data) {
        console.log('fdsssssssfdsfsf', data);
    }
})
//获取班组成员
var classpeople = new FormData();
$.ajax({
    url: baseUrl + 'api/Culture/GetDeptMembers',
    type: "POST",
    data: {
        json: JSON.stringify({
            "userId": userId,
            "data": {
                "bzId": bzId
            }
        })
    },
    success: function (data) {
        if (data.code == 0) {
            peopleList = data.data;
            getperson();
        }
        console.log(peopleList);
        // peopleList = 
    }
})

function getperson() {
    var x = "";
    for (var i = 0; i < peopleList.length; i++) {
        x += '<div class="pre-item">' +
            '<div class="pre-top">' +
            '<div class="pre-name">' + peopleList[i].Name + '</div>' +
            '<div class="p-j-job">' + peopleList[i].Quarters + '</div>' +
            '</div>' +
            '<div class="imgIcon">' +
            '<img src="' + (peopleList[i].Photo ? peopleList[i].Photo : photoImg) + '" alt="">' +
            '</div>' +
            '</div>'
    }
    $("#peopleQ").html(x);
}
//月度工作任务评分
// $.ajax(
//     {
//         url:baseUrl+'api/Culture/GetMonthScore',
//         data:JSON.stringify({
//             "userId":,
//             "data":{
//                 "bzId":bzId
//             }
//         }),
//         type:"POST",
//         contentType:false,
//         processData:false,
//         success:function(data){
//             console.log(data);
//         }
//     }
// )
//获取学习园地
$.ajax({
    url: baseUrl + 'api/Culture/GetLearningGardens',
    data: fd,
    type: "POST",
    contentType: false,
    processData: false,
    success: function (data) {
        console.log(data);
        studyarea(data.data);
    }
})

function studyarea(itemlist) {
    var studyarealist = "";
    for (var i = 0; i < itemlist.length; i++) {
        studyarealist += '<div class="bg-tab" data-url="' + itemlist[i].filepath + '"><a' +
            // download   target="_blank" href="'+itemlist[i].filepath+'"
            '>' + itemlist[i].filename + '</a></div>';
    }
    $(".m-m-clc-q").html(studyarealist);
    $(".bg-tab").click(
        function () {
            var urlpaths = $(this).attr('data-url');
            bzApi.downloadFile(urlpaths)
        }
    )
}

$("#instruTure").click(
    function () {

        saveInstru();
    }
)
$("#instruTures").click(
    function () {

        saveInstru1();
    }
)
//编辑保存简介
function saveInstru() {
    var summaryList = $("#editInstr").val();
    var summarydate = $(".edittimeinstru").val();
    console.log(summaryList);
    var SaveWallInfo = new FormData();
    var saveParams = {
        userId: userId,
        data: {
            bzId: bzId,
            summary: summaryList,
            summarydate: summarydate,
            savetype: "summary"
            // concept:"dssssssssssssssssssssss",
            // slogan:"bbbbb",
            // vision:"cccc"
        }
    }
    SaveWallInfo.append(
        'json', JSON.stringify(saveParams)
    )
    $.ajax({
        url: baseUrl + 'api/Culture/SaveWallInfo',
        data: SaveWallInfo,
        type: "POST",
        contentType: false,
        processData: false,
        success: function (data) {
            if (changeMsg == "zred") {
                location.href = "./detail1.html?number=1&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
            } else if (changeMsg == "zgblue") {
                location.href = "./detail2.html?number=1&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
            } else if (changeMsg == "zgreen") {
                location.href = "./detail3.html?number=1&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
            } else if (changeMsg == "zorange") {
                location.href = "./detail4.html?number=1&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
            }
            console.log(data);
        }
    })
}
//编辑保存愿景
function saveInstru1() {
    var summaryList = $("#edithope").val();
    var visiondate = $(".hopetime").val();

    console.log(visiondate);
    var SaveWallInfo = new FormData();
    var saveParams = {
        userId: userId,
        data: {
            bzId: bzId,
            vision: summaryList,
            visiondate: visiondate,
            savetype: "vision"
            // concept:"dssssssssssssssssssssss",
            // slogan:"bbbbb",
            // vision:"cccc"
        }
    }
    SaveWallInfo.append(
        'json', JSON.stringify(saveParams)
    )
    $.ajax({
        url: baseUrl + 'api/Culture/SaveWallInfo',
        data: SaveWallInfo,
        type: "POST",
        contentType: false,
        processData: false,
        success: function (data) {
            if (changeMsg == "zred") {
                location.href = "./detail1.html?number=5&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
            } else if (changeMsg == "zgblue") {
                location.href = "./detail2.html?number=5&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
            } else if (changeMsg == "zgreen") {
                location.href = "./detail3.html?number=5&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
            } else if (changeMsg == "zorange") {
                location.href = "./detail4.html?number=5&userId=" + userId + "&bzId=" + bzId + "&regDeptId=" + regDeptId;
            }
            // location.href="./detail1.html?number=2"
        }
    })
}

$(".toimg img").attr("src", "../img/detail/1/" + changeMsg[0] + ".png");


function jianjie() {
    $.ajax({
        // contentType:"application/json; charset=utf-8",
        url: baseUrl + 'api/Culture/GetWallInfo',
        data: fd,
        type: "POST",
        contentType: false,
        processData: false,
        success: function (data) {
            if (data.code == 0) {
                // mainclass(data.data)
                // mainclass(data.data)
                $("#editInstr").val(data.data.summary)
                $("#edithope").val(data.data.vision)
            }
        }
    })
}

function prewimg(item){
}